<?php



namespace App\Services\Business\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Query\Builder;

/**
 * 模型类
 * @method static Builder corpId($corp_id)
 *
 */
class TagCategory extends Model
{
    use HasFactory;

    protected $table = 'tag_category';

    protected $fillable = [
        'sort', 'name', 'parent_id', 'parent_chain', 'company_id',
    ];



    /**
     * @param $query
     * @return mixed
     */
    public function scopeShow($query)
    {
        return $query->where('is_show', 1);
    }

    /**
     * @param $query
     * @return mixed
     */
    public function scopeSort($query)
    {
        return $query->orderBy('sort');
    }

    public function children()
    {
        return $this->hasMany(__CLASS__, 'parent_id');
    }
}
